package com.thb.pay.comm.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description 支付网关自定义返回对象
 * @Author lucky
 * @data 2019/10/19 21:52
 */
public class PaymentResult extends HashMap<String, Object> {
    public static final String RESULT_CODE_KEY = "resultCode";
    public static final String RESULT_MESSAGE_KEY = "resultMsg";
    public static final String RESULT_TIME_KEY = "timestamp";
    public static final String RESULT_DATA_KEY = "resultData";
    public static final Integer SUCCESS_CODE = 200;
    public static final Integer SYSTEM_ERROR_CODE = 500;
    private static final long serialVersionUID = 1L;
    private static final String SUCCESS_MSG = "SUCCESS";
    private static final String SYSTEM_ERROR_MSG = "未知异常，请联系管理员";

    public PaymentResult() {
        put(RESULT_CODE_KEY, SUCCESS_CODE);
        put(RESULT_MESSAGE_KEY, SUCCESS_MSG);
        put(RESULT_TIME_KEY, System.currentTimeMillis());
    }

    public static PaymentResult error() {
        return error(SYSTEM_ERROR_CODE, SYSTEM_ERROR_MSG);
    }

    public static PaymentResult error(String msg) {
        PaymentResult result = error(SYSTEM_ERROR_CODE, msg);
        return result;
    }

    public static PaymentResult error(int code, String msg) {
        PaymentResult result = new PaymentResult();
        result.put("code", code);
        result.put("msg", msg);
        return result;
    }

    public static PaymentResult ok(String msg) {
        PaymentResult result = new PaymentResult();
        result.put("msg", msg);
        return result;
    }

    public static PaymentResult ok(Object data, String secretKey) {
        PaymentResult result = new PaymentResult().put(RESULT_DATA_KEY, data);
        return result;
    }

    public static PaymentResult ok() {
        PaymentResult result = new PaymentResult();
        return result;
    }

    public static PaymentResult okData(Object data) {
        PaymentResult result = new PaymentResult().put(RESULT_DATA_KEY, data);
        return result;
    }

    public static PaymentResult builder() {
        PaymentResult result = new PaymentResult();
        return result;
    }

    public PaymentResult put(String key, Object value) {
        super.put(key, value);
        return this;
    }

    public PaymentResult build(Map<String, Object> resultObj, String signKey) {
        return this;
    }

    public PaymentResult build() {
        return this;
    }
}
